<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%@ include file="Connections/conDB.jsp" %>
<% int validaSession = 2; %>
<%@ include file="Connections/session.jsp" %>

<%
String parId_unidad = request.getParameter("id_unidad");
//out.print(parId_unidad);
%>
<html>
<head>
<title>CIMA v2 - Nuevo Motivo/Lote - Unidad</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="miestilo.css" type="text/css">
<script>
var win1 = null;
//-------
function loteCat(){
	//document.form1.action="compras_invent.jsp";
	win1 = window.open('motivolote_catalogo.jsp?campo1=motLoteCod&campo2=motLoteId&campo3=motLoteIdDesc','LoteNum','top=350,left=400,width=340,height=270');
}	
//---------
	function cierraVentanas(){
		obj1 = eval("win1");
		if (obj1 && !obj1.closed) {
			obj1.close();
		}			
	}
//----------
function enviaSubmit() {
		if (valida()) {
			document.form1.submit();
		}
	}
//--------
function noEsNum(num,opc){
	var checkOK = "";
	if (opc==1) {
		checkOK = "1234567890.";
	} else {
		checkOK = "1234567890";
	}
	var checkStr =num; // quantity.value;
	var allValid = true;
	for(i=0;i<checkStr.length;i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++){
		      if (ch == checkOK.charAt(j))
	      	  break;
		}
		if (j == checkOK.length){
		     allValid = false;
		    	break;
		}
	}
	if(!allValid){
		return false;
	 }else{
		if (isNaN(num)){ //quantity.value)){
			return false;
	
		}else{
			return true;
		}
	} // fin if (!allValid)

}
//----------
function valida() {
	var Doc = document.form1;
	missinginfo = "";
	if (Doc.motLoteId.value =="")  missinginfo += "\n     - Motivo/Lote";
	if (Doc.motLoteCod.value =="")  missinginfo += "\n     - Motivo/Lote";
	if (Doc.cantidad.value == "")     missinginfo += "\n     - Cantidad";
		else if (!noEsNum(Doc.cantidad.value,1)) missinginfo += "\n     - Dato no valido\n          en Cantidad";

	if (missinginfo != "") {
		missinginfo = "Favor de llenar los siguientes campos:\n_____________________________\n" + missinginfo +
					  "\n_____________________________\n";
		alert(missinginfo);
		return false;
	}else{
		return true;
	}
}
//--------
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" background="images/fondo.jpg" leftmargin="0" topmargin="0" onUnload="cierraVentanas()">
<center>
<br>
  <form name="form1" method="post" action="lote_unidad_querys.jsp">
    <table width="210" border="0" cellspacing="0" cellpadding="0">
      <tr align="center"> 
        <td colspan="3" class="titulos">Nuevo Motivo/Lote - Unidad</td>
    </tr>
    <tr> 
        <td align="right" class="etiqueta" width="75">&#149; Motivo/Lote</td>
      <td width="7">&nbsp;</td>
      <td>
          <input type="text" name="motLoteCod" class="textfields" size="15">
          <input type="hidden" name="motLoteId">
          <input type="hidden" name="motLoteIdDesc">
          <a href="javascript:loteCat()"><img src="images/buscar.gif" width="15" height="15" class="cursor" border="0"></a>
        </td>
    </tr>
    <tr> 
        <td align="right" class="etiqueta">&#149; Cantidad</td>
      <td>&nbsp;</td>
      <td>
          <input type="text" name="cantidad" class="textfields" size="15" maxlength="15">
          ton </td>
    </tr>
      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr align="right"> 
        <td colspan="3" class="nota">&#149; Datos Requetridos</td>
      </tr>
  </table>
<br>
    <table width="200" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center">
	        <input type="hidden" name="modalidad" value="nuevo">
	        <input type="hidden" name="id_unidad" value="<%=parId_unidad%>">
		  <a href="javascript:enviaSubmit()"><img src="images/bGuardar.gif" width="83" height="18" border="0"></a>&nbsp; 
		<a href="javascript:window.close()"><img src="images/bCerrar.gif" width="82" height="18" border="0"></a></td>
      </tr>
    </table>
</form>
</center>
</body>
</html>
